home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
gc
/
GCmach_dep.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-04-19
|
7KB
|
173 lines
/* begincopyright
Copyright (c) 1988,1990 Xerox Corporation. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
PCR Coordinator
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA 94304
Parts of this software were derived from code bearing the copyright notice:
Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
This material may be freely distributed, provided this notice is retained.
This material is provided as is, with no warranty expressed or implied.
Use at your own risk.
endcopyright */
# include "xr/GCPrivate.h"
# include <setjmp.h>
/*
* Boehm, March 8, 1990 6:13:16 pm PST
*/
/* On register window machines, we need a way to flush the registers. */
# ifdef SPARC
# include <sun4/trap.h>
asm(" .globl _GC_save_regs_in_stack");
asm("_GC_save_regs_in_stack:");
asm(" t 0x3 ! ST_FLUSH_WINDOWS");
asm(" mov %sp,%o0");
asm(" retl");
asm(" nop");
# endif
/* Routine to mark from registers that are preserved by the C compiler. */
/* This must be ported to every new architecture. There is a generic */
/* version at the end, that is likely, but not guaranteed to work */
/* on your architecture. Run the test_setjmp program to see whether */
/* there is any chance it will work. */
/* SPARC version assumes it is called before the stack is marked. */
GC_mark_regs()
{
# ifdef RT
register long TMP_SP; /* must be bound to r11 */
# endif
# ifdef VAX
/* VAX - generic code below does not work under 4.2 */
/* r1 through r5 are caller save, and therefore */
/* on the stack or dead. */
asm("pushl r11"); asm("calls $1,_GC_tl_mark");
asm("pushl r10"); asm("calls $1,_GC_tl_mark");
asm("pushl r9"); asm("calls $1,_GC_tl_mark");
asm("pushl r8"); asm("calls $1,_GC_tl_mark");
asm("pushl r7"); asm("calls $1,_GC_tl_mark");
asm("pushl r6"); asm("calls $1,_GC_tl_mark");
# endif
# ifdef M68K_SUN
/* M68K_SUN - could be replaced by generic code */
/* a0, a1 and d1 are caller save */
/* and therefore are on stack or dead. */
asm("subqw #0x4,sp"); /* allocate word on top of stack */
asm("movl a2,sp@"); asm("jbsr _GC_tl_mark");
asm("movl a3,sp@"); asm("jbsr _GC_tl_mark");
asm("movl a4,sp@"); asm("jbsr _GC_tl_mark");
asm("movl a5,sp@"); asm("jbsr _GC_tl_mark");
/* Skip frame pointer and stack pointer */
asm("movl d1,sp@"); asm("jbsr _GC_tl_mark");
asm("movl d2,sp@"); asm("jbsr _GC_tl_mark");
asm("movl d3,sp@"); asm("jbsr _GC_tl_mark");
asm("movl d4,sp@"); asm("jbsr _GC_tl_mark");
asm("movl d5,sp@"); asm("jbsr _GC_tl_mark");
asm("movl d6,sp@"); asm("jbsr _GC_tl_mark");
asm("movl d7,sp@"); asm("jbsr _GC_tl_mark");
asm("addqw #0x4,sp"); /* put stack back where it was */
# endif
# ifdef M68K_HP
/* M68K_HP - could be replaced by generic code */
/* a0, a1 and d1 are caller save. */
asm("subq.w &0x4,%sp"); /* allocate word on top of stack */
asm("mov.l %a2,(%sp)"); asm("jsr _GC_tl_mark");
asm("mov.l %a3,(%sp)"); asm("jsr _GC_tl_mark");
asm("mov.l %a4,(%sp)"); asm("jsr _GC_tl_mark");
asm("mov.l %a5,(%sp)"); asm("jsr _GC_tl_mark");
/* Skip frame pointer and stack pointer */
asm("mov.l %d1,(%sp)"); asm("jsr _GC_tl_mark");
asm("mov.l %d2,(%sp)"); asm("jsr _GC_tl_mark");
asm("mov.l %d3,(%sp)"); asm("jsr _GC_tl_mark");
asm("mov.l %d4,(%sp)"); asm("jsr _GC_tl_mark");
asm("mov.l %d5,(%sp)"); asm("jsr _GC_tl_mark");
asm("mov.l %d6,(%sp)"); asm("jsr _GC_tl_mark");
asm("mov.l %d7,(%sp)"); asm("jsr _GC_tl_mark");
asm("addq.w &0x4,%sp"); /* put stack back where it was */
# endif /* M68K_HP */
# ifdef I386
/* I386 code, generic code does not appear to work */
asm("pushl %eax"); asm("call _GC_tl_mark"); asm("addl $4,%esp");
asm("pushl %ecx"); asm("call _GC_tl_mark"); asm("addl $4,%esp");
asm("pushl %edx"); asm("call _GC_tl_mark"); asm("addl $4,%esp");
asm("pushl %esi"); asm("call _GC_tl_mark"); asm("addl $4,%esp");
asm("pushl %edi"); asm("call _GC_tl_mark"); asm("addl $4,%esp");
asm("pushl %ebx"); asm("call _GC_tl_mark"); asm("addl $4,%esp");
# endif
# ifdef NS32K
asm ("movd r3, tos"); asm ("bsr ?_GC_tl_mark"); asm ("adjspb $-4");
asm ("movd r4, tos"); asm ("bsr ?_GC_tl_mark"); asm ("adjspb $-4");
asm ("movd r5, tos"); asm ("bsr ?_GC_tl_mark"); asm ("adjspb $-4");
asm ("movd r6, tos"); asm ("bsr ?_GC_tl_mark"); asm ("adjspb $-4");
asm ("movd r7, tos"); asm ("bsr ?_GC_tl_mark"); asm ("adjspb $-4");
# endif
# ifdef SPARC
/* generic code will not work */
GC_save_regs_in_stack();
# endif
# ifdef RT
GC_tl_mark(TMP_SP); /* GC_tl_mark from r11 */
asm("cas r11, r6, r0"); GC_tl_mark(TMP_SP); /* r6 */
asm("cas r11, r7, r0"); GC_tl_mark(TMP_SP); /* through */
asm("cas r11, r8, r0"); GC_tl_mark(TMP_SP); /* r10 */
asm("cas r11, r9, r0"); GC_tl_mark(TMP_SP);
asm("cas r11, r10, r0"); GC_tl_mark(TMP_SP);
asm("cas r11, r12, r0"); GC_tl_mark(TMP_SP); /* r12 */
asm("cas r11, r13, r0"); GC_tl_mark(TMP_SP); /* through */
asm("cas r11, r14, r0"); GC_tl_mark(TMP_SP); /* r15 */
asm("cas r11, r15, r0"); GC_tl_mark(TMP_SP);
# endif
# if 0
/* Generic code */
/* The idea is due to Parag Patel at HP. */
/* We're not sure whether he would like */
/* to be he acknowledged for it or not. */
{
jmp_buf regs;
register word * i = (word *) regs;
register word * lim = (word *) (((char *)(regs)) + (sizeof regs));
/* Setjmp on Sun 3s doesn't clear all of the buffer. */
/* That tends to preserve garbage. Clear it. */
for (; i < lim; i++) {
*i = 0;
}
(void) _setjmp(regs);
GC_tl_mark_all(regs, lim);
}
# endif
/* other machines... */
# if !(defined M68K_SUN) && !defined(M68K_HP) && !(defined VAX) && !(defined RT) && !(defined SPARC) && !(defined I386) &&!(defined NS32K)
--> bad news <--
# endif
}